package com.lxs.mall.util;

import java.security.SecureRandom;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * 生成订单No工具类
 *
 * @author 小松
 */
public class OrderCodeFactory {
    private static String getDateTime() {
        DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        return sdf.format(new Date());
    }

    private static int getRandom(Integer n) {
        Random random = new SecureRandom();
        return (int) (random.nextDouble() * (90000)) + 10000;
    }

    public static String getOrderCode(Integer userId) {
        return getDateTime() + getRandom(userId);
    }
}
